<?php
/**
 * Created by PhpStorm.
 * User: deng
 * Date: 2015/2/23
 * Time: 23:59
 */
namespace Test\Controller;

use Lab\Model\DB;

class TestController extends \Think\Controller
{
    function test()
    {
        $db = DB::build();
        exit;
        if($db->users->findAll(0, 2)['total'] == 0) {
            $userId = $db->users->create([
                'info' => [
                    'name' => 'xiaoming',
                    'portrait' => 'none'
                ]
            ]);

            $db->users->create([
                'info' => [
                    'name' => 'xiaoming2',
                    'portrait' => 'none'
                ]
            ]);
        } else {
            $userId = $db->users->id->findAll(0, 2, 'info.name')['list'][0];
        }
        echo $userId."\n";

        $db->users->auth->update($userId, [
            'username' => 'xiaoming', 'password' => 'youknow'
        ]);

        print_r($db->users->find($userId));

        print_r($db->users->info->find($userId));

        print_r($db->users->info->findBy(['username' => 'xiaoming']));

        print_r($db->users->info->findAll(0, 2));

        print_r($db->users->info->findAllBy(
            ['/portrait' => 'none'], ['name'], 0, 2, 'info.name asc'));


        var_dump($db->labs->find('1'));

        var_dump($db->labs->notices->find('1'));
    }
}